package com.mytrans.config;

import com.mytrans.transaction.*;
import com.mytrans.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;

public class MytransConfig {

    private TokenManager tokenManager;

    private TransactionListener transactionManagerClient;

    private ExecutorContainer executorContainer;

    private ApplicationContext applicationContext;

    public TokenManager getTokenManager() {
        return tokenManager;
    }

    public MytransConfig(ExecutorContainer executorContainer, TransactionListener transactionManagerClient,
                         ApplicationContext applicationContext){
        this.executorContainer = executorContainer;
        this.transactionManagerClient = transactionManagerClient;
        this.tokenManager = new DefaultTokenManager();
        this.applicationContext = applicationContext;
        SpringUtil.setApplicationContext(applicationContext);
    }

    public MytransConfig setTokenManager(TokenManager tokenManager) {
        this.tokenManager = tokenManager;
        return this;
    }

    public TransactionListener getTransactionManagerClient() {
        return transactionManagerClient;
    }

    public MytransConfig setTransactionManagerClient(TransactionListener transactionManagerClient) {
        this.transactionManagerClient = transactionManagerClient;
        return this;
    }

    public ExecutorContainer getExecutorContainer() {
        return executorContainer;
    }

    public MytransConfig setExecutorContainer(ExecutorContainer executorContainer) {
        this.executorContainer = executorContainer;
        return this;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public MytransConfig setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
        return this;
    }
}
